package com.zhiyou100.crm.servlet.message;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zhiyou100.crm.pojo.AdminBaseServlet;
import com.zhiyou100.crm.pojo.Message;
import com.zhiyou100.crm.service.MessageService;
import com.zhiyou100.crm.service.impl.MessageServiceImpl;

/**
 * 邮件详情
 */
@WebServlet("/message/detail")
public class DetailServlet extends AdminBaseServlet {
	private static final long serialVersionUID = 1L;
	MessageService messageService=new MessageServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int messageId = Integer.parseInt(request.getParameter("id"));
		List<Message> messages = messageService.queryMessage();
		for (int i = 0; i < messages.size(); i++) {
			if(messageId==(messages.get(i).getMessage_id())){
				request.setAttribute("message",messages.get(i));
				break;
			}
		}
		request.getRequestDispatcher("/WEB-INF/view/message/detail.jsp").forward(request, response);
	}

}
